﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace JEdwonTune.Common {
    public partial class FrmXmlNodeEditorBase : Form {
        public FrmXmlNodeEditorBase() {
            InitializeComponent();
        }
        private XmlNode _Node;
        public XmlNode Node {
            set { _Node = value; }
            get { return _Node; }
        }
        private XmlNode _Parent;
        public XmlNode TheParent {
            set { _Parent = value; }
            get { return _Parent; }
        }
        private XmlDocument _Doc;
        public XmlDocument Doc {
            set { _Doc = value; }
            get { return _Doc; }
        }

        public void SetNodeAttrValue(XmlNode node,String attr, String val) {
            if (node.Attributes[attr] != null) {
                node.Attributes[attr].Value = val;
            } else {
                XmlAttribute xa = _Doc.CreateAttribute(attr);
                xa.Value = val;
                node.Attributes.Append(xa);
            }
        }
        public void RemoveNodeAttr(XmlNode node, String attr) {
            if (node.Attributes[attr] != null) {
                node.Attributes.Remove(node.Attributes[attr]);
            }
        }
    }
}
